package com.usian.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.usian.mapper.dep.DepMapper;
import com.usian.mapper.poste.PosteMapper;
import com.usian.mapper.staff.StaffMapper;
import com.usian.pojo.dep.Dep;
import com.usian.pojo.staff.Staff;
import com.usian.service.DepService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DepServiceImpl implements DepService {


    @Autowired
    private DepMapper depMapper;

    @Autowired
    private StaffMapper staffMapper;

    @Autowired
    private PosteMapper posteMapper;

    @Override
    public List<Dep> dlist() {
        List<Dep> all = depMapper.all();
        return all;
    }

    @Override
    public void ad(Dep dep) {
        depMapper.insert(dep);
    }


    @Override
    public void dele(Integer did) {
        int id = staffMapper.findById(did);
        if (id==0){
            Integer depId= did;
            posteMapper.deleteById(depId);
            depMapper.deleteById(did);
        }
    }
}
